<template>
	<view class="print">
		 <view class="icon" @click="showPrint"><wd-icon name="print" size="22px" color="white"></wd-icon>打印</view>
		 <th-dialog title="打印" v-model:visible="printShow">
				<template v-slot:content>
				<view class="wrap">
					<view class="topic">
						来样打印
					</view>
					<uni-print-button
						size="small"
						class="btn"
						kind="demand"
						type="primary"
						:data="[{...data}]"
					 >
					  打印
					 </uni-print-button>
					<view class="topic">
						送样打印
					</view>
					品名：
					<th-input mode="textarea" border placeholder="请输入品名" autoHeight v-model:value="invName"></th-input>
					规格：
					<th-input mode="textarea" border placeholder="请输入规格" autoHeight v-model:value="invStd"></th-input>
					<view style="display: flex;align-items: center;justify-content: space-between">
						<uni-wifi-print
						size="small"
						class="btn"
						type="primary"
						kind="demand"
						:data="[{invName,invStd}]"
						 >
						   打印
						 </uni-wifi-print>
						 <th-button size="small"  @click="restHandle">
						 	重置
						 </th-button>
					</view>
				</view>
				</template>
		 </th-dialog>
	 </view>
</template>

<script setup name="th-print">
    import thDialog from './th-dialog.vue';
	import thButton from './th-button.vue';
	import thInput from './th-input.vue';
	import UniPrintButton from '@/pages/pm/assay-report/component/uniPrintButton.vue';
	import UniWifiPrint from '@/pages/pm/assay-report/component/uniWifiPrint.vue';
    import { request } from '@/utils/request';

	const printShow = ref(false);
	const invName = ref('');
	const invStd = ref('');
	const code = ref('')
	
	
	const showPrint = ()=>{
		printShow.value = true;
	}
	
	const props = defineProps({
	  data: {
	    type: Object,
	    default: () => {
	      return {};
	    },
	  }
	});
	
	const restHandle = ()=>{
		if(code.value.indexOf('_101_')>0){
			invName.value = props.data.invName;
		}else{
			invName.value = props.data.invEnName || props.data.invName;
		}
		invStd.value = props.data.invStd;
	}
	
	onMounted(()=>{
		return request({
			url: `/admin/tenant/details/${props.data.tenantId}`,
			method: 'GET'
		}).then(res=>{
			code.value = res.data.code;
			if(res.data.code.indexOf('_101_')>0){
				invName.value = props.data.invName;
			}else{
				invName.value = props.data.invEnName || props.data.invName;
			}
			invStd.value = props.data.invStd;
		})
	})
	
	
</script>

<style lang="scss" scoped>
.print{
  .icon{
	  display: flex;
	  item-align:center;
	  color:#fff;
  }
  .wrap{
	  margin:0 20rpx;
	  text-align: left;
	  border:1rpx solid rgba(0,0,0,0);
	  .topic{
		 padding-left:15rpx;
		 margin-top:15rpx;
		 height:50rpx;
		 display: flex;
		 align-items:center;
		 // border:1rpx solid red;
		 font-weight:bold;
		 position:relative;
		 &::before{
			 position: absolute;
			 top: 8rpx;
			 bottom: 8rpx;
			 left: 0;
			 width: 8rpx;
			 content: "";
			 background-color: #2e5cf6;
			 border-radius: 3rpx;
		 }
	  }
  }

}
:deep(.wd-navbar__right--hover) {
  background: none!important;
}
</style>